import prisma from '@/server/lib/prisma';

export default defineEventHandler(async (event) => {
  try {
    const userCount = await prisma.sys_user.count();
    const roleCount = await prisma.sys_role.count();
    const postCount = await prisma.sys_post.count();
    const deptCount = await prisma.sys_dept.count();
    return {
      code: 200,
      data: {
        userCount,
        roleCount,
        postCount,
        deptCount
      }
    }
  } catch (e) {
    throw e;
  } finally {
    await prisma.$disconnect(); // 关闭连接
  }
})